<?php

class Admin_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	$this->_helper->layout()->setLayout("main");
    }

    public function indexAction()
    {
		
		
    }
    
    public function loginAction(){
    	$request=$this->getRequest();
    	$module=$request->getModuleName();
    	$controller=$request->getControllerName();
    	$action=$request->getActionName();
		$usersNs = new Zend_Session_NameSpace("users");
		if($usersNs->userId!=null){
			$this->_helper->redirector('index','index','admin');
		}
    	$form=new Application_Form_UserLogin();
		$this->view->form=$form;
		if($this->getRequest()->isPost()){
			$formData=$this->getRequest()->getPost();
			if($form->isValid($formData)){
				$userName=$form->getValue('userName');
				$userPass=$form->getValue('userPass');
				if($userName=='admin'&&$userPass='174914225'){
					$usersNs->userName='admin';
					$usersNs->userType='admin';
					$this->_helper->redirector('index','index','admin');
				}
			}	
		}
    }


}

